package com.gamefx.resource
{
	import flash.events.Event;
	import flash.net.URLStream;
	import flash.utils.ByteArray;
	import flash.utils.getQualifiedClassName;

	public class DataLoader extends LoaderItem
	{
		public function DataLoader(urlOrRequest:*, priority:uint=1, estimatedBytes:uint=0)
		{
			super(urlOrRequest, priority, estimatedBytes);

			if (getQualifiedClassName(this) == "com.gamefx.resource::DataLoader")
			{
				throw new Error("DataLoader can't instantiation, can only be inherited.");
			}
		}
		
		
		override internal function onComplete(event:Event):void
		{
			var stream:URLStream = event.currentTarget as URLStream;
			var bytes:ByteArray = new ByteArray();
			stream.readBytes(bytes);
			
			onDataComplete(event, bytes);
		}
		
		/**
		 * plese override this method.
		 * 
		 * @param data
		 */
		protected function onDataComplete(event:Event, bytes:ByteArray):void
		{
			super.onComplete(event);
		}
	}
}